SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO





CREATE VIEW [dbo].[SSB_CUSIP_Map_ALLTIME] AS




SELECT DISTINCT  i.extid AS FS_ID, ssr.CUSIP AS SSB_ID

 FROM  FSFundModel.dbo.StateStreetRecon ssr

 INNER JOIN  FSFundModel.dbo.AssetIdentifier ai
 ON ai.AssetId = ssr.StateStreetIdentifier
 INNER JOIN  FSFundModel.dbo.Instrument i ON
 ai.InstrumentId = i.InstrumentId 


















--INNER JOIN  FSFundModel.Reporting.AssetIdentifier ai
--ON ai.AssetId = ssr.StateStreetIdentifier
--INNER JOIN FSFundModel.Reporting.Instrument i ON
--ai.InstrumentId = i.InstrumentId
--AND ai.ExportId = i.ExportId
--INNER JOIN  FSFundModel.Reporting.Asset a ON
--ai.InstrumentId = a.InstrumentId
--AND ai.PortfolioId  = a.PortfolioId
--AND ai.LotId = a.LotId
--AND ai.ExportId = a.ExportId 

--WHERE ai.ExportId =(SELECT MAX(e.ExportId) FROM FSFundModel.Reporting.Export e WHERE e.FundId ='FSIC' AND e.NAVDate < '9/15/2013')

--AND a.IsActiveEndOfDay = 1





GO
